<div class="page-header">
    <h1>
        用户登录日志
        <small>
            <i class="ace-icon fa fa-angle-double-right"></i>
        </small>
    </h1>
</div>
<div class="row">
    <div class="col-xs-12">
        <table id="dtpList" class="dataTable">
            <!--<tfoot>-->
            <!--<tr>-->
            <!--<td colspan="4">本页合计：</td>-->
            <!--<td>-->
            <!--<span name="Coin" class="tooltip-"/>-->
            <!--</td>-->
            <!--<td>-->
            <!--<span name="Beans" class="tooltip-"/>-->
            <!--</td>-->
            <!--<td colspan="10"></td>-->
            <!--</tr>-->
            <!--</tfoot>-->
        </table>
        <div id="dtpList_filter" class="dataTables_filter">
            <div>
                <select id="dtpList_F_SType" class="selectpicker" data-style="btn btn-info btn-sm" data-width="90px">
                    <option value="">模糊查询</option>
                    <option data-divider="true"></option>
                    <option value="Log_ID">日志ID</option>
                    <option value="User_ID">用户ID</option>
                    <option value="NickName">用户昵称</option>
                    <option value="RealName">真实姓名</option>
                    <option value="Channel_ID">渠道ID</option>
                    <option value="Inviter_ID">邀请人ID</option>
                    <option value="SignUp_Anchor_ID">转化房间ID</option>
                    <option value="SignUp_Anchor_Family_ID">转化公会ID</option>
                </select>
                <input id="dtpList_F_SValue" class="fvalue" type="text"/>
                <select id="dtpList_F_DateType">
                    <option value="Create_Date">登录时间</option>
                    <option value="SignUp_Date">注册时间</option>
                </select>
                <input id="dtpList_F_StartDate" type="text" style="width: 76px;" placeholder="开始时间">
                <label>-</label>
                <input id="dtpList_F_EndDate" type="text" style="width: 76px;" placeholder="结束时间">
                <select id="dtpList_F_SelectDate"></select>
                <label>登录方式：</label>
                <select id="dtpList_F_SignInType">
                    <option value="-1">所有</option>
                    <option value="1">记住</option>
                    <option value="2">用户名（手机）</option>
                    <option value="10">QQ</option>
                    <option value="11">微信</option>
                    <option value="12">微博</option>
                </select>
                <a id="dtpList_F_Advanced"></a>
                <button id="dtpList_F_Btn"></button>
            </div>
            <div>
                <label>注册源：</label>
                <select id="dtpList_F_SignUpOrigin">
                    <option value="">所有</option>
                    <option value="0">PC</option>
                    <option value="100">Android</option>
                    <option value="300">iOS</option>
                </select>
                <label>登录源：</label>
                <select id="dtpList_F_SignInOrigin">
                    <option value="">所有</option>
                    <option value="0">PC</option>
                    <option value="100">Android</option>
                    <option value="300">iOS</option>
                </select>
                <label><input id="dtpList_F_IsChargeFirst" type="checkbox"/>&nbsp;首充</label>
                <label><input id="dtpList_F_IsIDCard" type="checkbox"/>&nbsp;实名</label>
                <label><input id="dtpList_F_IsAnchor" type="checkbox"/>&nbsp;艺人</label>
                <label><input id="dtpList_F_IsFamily" type="checkbox"/>&nbsp;公会</label>
                <label><input id="dtpList_F_IsAdmin" type="checkbox"/>&nbsp;管理员</label>
            </div>
        </div>
    </div>
</div>
<script src="<%- Virtual_Path.Static %>jquery.plugin/dataTables/jquery.dataTables.min.js"></script>
<script src="<%- Virtual_Path.Static %>jquery.plugin/dataTables/jquery.dataTables.bootstrap.min.js"></script>
<script>
    $(function () {
        //region 时间输入框插件
        $('#dtpList_F_StartDate, #dtpList_F_EndDate').datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            minView: 2,
            autoclose: true
        });
        //endregion
        //region 绑定日期选择框
        $.KOC.Date.Select.Bind({
            eSelect: $('#dtpList_F_SelectDate'),
            eBegin: $('#dtpList_F_StartDate'),
            eEnd: $('#dtpList_F_EndDate')
        });
        //endregion
        //region dtpList
        var _dtpList = $("#dtpList").dataTable({
            'aoColumns': [
                {
                    'sWidth': '75px', 'data': 'Log_ID', 'sName': 'Log_ID', 'sTitle': '日志ID', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        $(td).text(cellData);
                    }
                },
                {
                    'sWidth': '75px', 'data': 'User_ID', 'sName': 'User_ID', 'sTitle': '用户ID', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        $(td).html($('<a/>').attr('data-openwindow', ':UserInfo:' + cellData).text(cellData));
                    }
                },
                {
                    'data': 'NickName', 'sName': 'User_ID', 'sTitle': '昵称', 'sClass': 'center t-left',
                    'createdCell': function (td, cellData, rowData) {
                        $(td).html('<span class="Level_User_' + rowData.Level + '"></span>' + cellData);
                    }
                },
                {
                    'sWidth': '32px', 'data': 'IsIDCard', 'sTitle': '实', 'sClass': 'center', 'bSortable': false,
                    'createdCell': function (td, cellData) {
                        switch (cellData) {
                            case 0:
                                $(td).html('<i class="fa fa-window-close bigger-120 red" data-rel="tooltip" data-original-title="未认证" />');
                                break;
                            case 1:
                                $(td).html('<i class="fa fa-check-square bigger-120 green" data-rel="tooltip" data-original-title="实名认证" />');
                                break;
                            default:
                                $(td).html('<i class="fa fa-question bigger-120" data-rel="tooltip" data-original-title="未知" />');
                                break;
                        }
                    }
                },
                {
                    'sWidth': '32px', 'data': 'IsChargeFirst', 'sTitle': '充', 'sClass': 'center', 'bSortable': false,
                    'createdCell': function (td, cellData) {
                        switch (cellData) {
                            case 0:
                                $(td).html('<i class="fa fa-window-close bigger-120 red" data-rel="tooltip" data-original-title="否" />');
                                break;
                            case 1:
                                $(td).html('<i class="fa fa-check-square bigger-120 green" data-rel="tooltip" data-original-title="是" />');
                                break;
                            default:
                                $(td).html('<i class="fa fa-question bigger-120" data-rel="tooltip" data-original-title="未知" />');
                                break;
                        }
                    }
                },
                {
                    'sWidth': '110px', 'data': null, 'sTitle': '高级角色', 'sClass': 'center', 'bSortable': false,
                    'createdCell': function (td, cellData, rowData) {
                        var _html = '';
                        if (rowData.IsAnchor) {
                            _html += '<span class="label label-sm label-success middle" data-rel="tooltip" data-original-title="艺人">艺</span> ';
                        }
                        if (rowData.IsFamily) {
                            _html += '<span class="label label-sm label-info middle" data-rel="tooltip" data-original-title="公会">公</span> ';
                        }
                        if (rowData.IsAdmin) {
                            _html += '<span class="label label-sm label-danger middle" data-rel="tooltip" data-original-title="管理员">管</span> ';
                        }
                        $(td).html(_html);
                    }
                },
                {
                    'sWidth': '80px', 'data': null, 'sTitle': '登录方式', 'sClass': 'center', 'bSortable': false,
                    'createdCell': function (td, cellData, rowData) {
                        var _html = '';
                        if (rowData.SignIn_Type == 1) {
                            _html += '<i class="fa fa-check-square bigger-120" data-rel="tooltip" data-original-title="记住我" /> ';
                        }
                        if (rowData.SignIn_Type == 2) {
                            _html += '<i class="fa fa-phone-square bigger-120 text-warning" data-rel="tooltip" data-original-title="手机验证" /> ';
                        }
                        if (rowData.SignIn_Type == 10) {
                            _html += '<i class="fa fa-qq bigger-120 text-primary" data-rel="tooltip" data-original-title="QQ绑定" /> ';
                        }
                        if (rowData.SignIn_Type == 11) {
                            _html += '<i class="fa fa-weixin bigger-120 text-success" data-rel="tooltip" data-original-title="微信绑定" /> ';
                        }
                        if (rowData.SignIn_Type == 12) {
                            _html += '<i class="fa fa-weibo bigger-120 text-danger" data-rel="tooltip" data-original-title="微博绑定" /> ';
                        }
                        $(td).html(_html);
                    }
                },
                {
                    'sWidth': '9%', 'data': 'Channel_ID', 'sName': 'Channel_ID', 'sTitle': '渠道ID', 'sClass': 'center'
                },
                {
                    'sWidth': '45px', 'data': 'SignUp_Origin', 'sTitle': '注源', 'sClass': 'center', 'bSortable': false,
                    'createdCell': function (td, cellData) {
                        switch (cellData) {
                            case 0:
                                $(td).html('<i class="fa fa-desktop bigger-120" data-rel="tooltip" data-original-title="PC端注册" />');
                                break;
                            case 100:
                                $(td).html('<i class="fa fa-android bigger-120" data-rel="tooltip" data-original-title="Android端注册" />');
                                break;
                            case 300:
                                $(td).html('<i class="fa fa-apple bigger-120" data-rel="tooltip" data-original-title="iOS端注册" />');
                                break;
                            default:
                                $(td).html('<i class="fa fa-question bigger-120" data-rel="tooltip" data-original-title="未知" />');
                                break;
                        }
                    }
                },
                {
                    'sWidth': '45px', 'data': 'SignIn_Origin', 'sTitle': '登源', 'sClass': 'center', 'bSortable': false,
                    'createdCell': function (td, cellData) {
                        switch (cellData) {
                            case 0:
                                $(td).html('<i class="fa fa-desktop bigger-120" data-rel="tooltip" data-original-title="PC端登录" />');
                                break;
                            case 100:
                                $(td).html('<i class="fa fa-android bigger-120" data-rel="tooltip" data-original-title="Android端登录" />');
                                break;
                            case 300:
                                $(td).html('<i class="fa fa-apple bigger-120" data-rel="tooltip" data-original-title="iOS端登录" />');
                                break;
                            default:
                                $(td).html('<i class="fa fa-question bigger-120" data-rel="tooltip" data-original-title="未知" />');
                                break;
                        }
                    }
                },
                {
                    'sWidth': '35px', 'data': 'Inviter_ID', 'sName': 'Inviter_ID', 'sTitle': '邀', 'sClass': 'center', 'bSortable': false,
                    'createdCell': function (td, cellData) {
                        $(td).html(cellData > 0 ? $('<a/>').attr('data-openwindow', ':UserInfo:' + cellData).html('<i class="fa fa-check-square bigger-120 green" data-rel="tooltip" data-original-title="邀请人ID：' + cellData + '" />') : '');
                    }
                },
                {
                    'sWidth': '70px', 'data': 'SignUp_Anchor_ID', 'sName': 'SignUp_Anchor_ID', 'sTitle': '转化', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        $(td).html(cellData > 0 ? $('<a/>').attr('data-openwindow', ':UserInfo:' + cellData).text(cellData) : '');
                    }
                },
                {
                    'sWidth': '80px', 'data': 'SignUp_Anchor_Family_ID', 'sName': 'SignUp_Anchor_Family_ID', 'sTitle': '转化主播', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        $(td).html(cellData > 0 ? $('<a/>').attr('data-openwindow', ':UserInfo:' + cellData).text(cellData) : '');
                    }
                },
                {
                    'sWidth': '9%', 'data': 'Create_Date', 'sName': 'Log_ID', 'sTitle': '登录日期', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        $(td).text(moment(cellData).format('YY/MM/DD HH:mm'));
                    }
                },
                {
                    'sWidth': '9%', 'data': 'SignUp_Date', 'sName': 'User_ID', 'sTitle': '注册日期', 'sClass': 'center',
                    'createdCell': function (td, cellData) {
                        $(td).text(moment(cellData).format('YY/MM/DD HH:mm'));
                    }
                }
            ],
            'aaSorting': [0, 'desc'],
            'sAjaxSource': '/ajax/log.page.userlogin',
            'fnServerParams': function (aoData) {
                if (!this.arrPageFilter) {
                    this.arrPageFilter = {
                        F_DateType: $(this.selector + '_F_DateType').val(),
                        F_StartDate: $(this.selector + '_F_StartDate').val(),
                        F_EndDate: $(this.selector + '_F_EndDate').val(),
                        F_SignUpOrigin: $(this.selector + '_F_SignUpOrigin').val(),
                        F_SignInOrigin: $(this.selector + '_F_SignInOrigin').val(),
                        F_SignInType: $(this.selector + '_F_SignInType').val(),
                        F_IsChargeFirst: $(this.selector + '_F_IsChargeFirst').is(':checked') ? 1 : -1,
                        F_IsIDCard: $(this.selector + '_F_IsIDCard').is(':checked') ? 1 : -1,
                        F_IsAnchor: $(this.selector + '_F_IsAnchor').is(':checked') ? 1 : -1,
                        F_IsFamily: $(this.selector + '_F_IsFamily').is(':checked') ? 1 : -1,
                        F_IsAdmin: $(this.selector + '_F_IsAdmin').is(':checked') ? 1 : -1
                    };
                } else {
                    $(this.selector + '_F_DateType').val(this.arrPageFilter.F_DateType);
                    $(this.selector + '_F_StartDate').val(this.arrPageFilter.F_StartDate);
                    $(this.selector + '_F_EndDate').val(this.arrPageFilter.F_EndDate);
                    $(this.selector + '_F_SignUpOrigin').val(this.arrPageFilter.F_SignUpOrigin);
                    $(this.selector + '_F_SignInOrigin').val(this.arrPageFilter.F_SignInOrigin);
                    $(this.selector + '_F_SignInType').val(this.arrPageFilter.F_SignInType);
                    $(this.selector + '_F_IsChargeFirst').prop('checked', this.arrPageFilter.F_IsChargeFirst == 1);
                    $(this.selector + '_F_IsIDCard').prop('checked', this.arrPageFilter.F_IsIDCard == 1);
                    $(this.selector + '_F_IsAnchor').prop('checked', this.arrPageFilter.F_IsAnchor == 1);
                    $(this.selector + '_F_IsFamily').prop('checked', this.arrPageFilter.F_IsFamily == 1);
                    $(this.selector + '_F_IsAdmin').prop('checked', this.arrPageFilter.F_IsAdmin == 1);
                }
                this.ofnServerParams(aoData);
            },
            'fnFooterCallback': function (nFoot, aData) {
                var _FooterData = {
                    Coin: 0,
                    Beans: 0
                };
                _.forEach(aData, function (ThisValue) {
                    _FooterData.Coin += ThisValue.Coin;
                    _FooterData.Beans += ThisValue.Beans;
                });
                $(nFoot).find('[name="Coin"]').attr({
                    'data-rel': 'tooltip',
                    'data-original-title': '金币价值总计：' + $.KOC.String.ToCurrencyPositiveStr(_FooterData.Coin / 1000)
                }).text(_FooterData.Coin);
                $(nFoot).find('[name="Beans"]').attr({
                    'data-rel': 'tooltip',
                    'data-original-title': '金豆价值总计：' + $.KOC.String.ToCurrencyPositiveStr(_FooterData.Beans / 1000)
                }).text(_FooterData.Beans);
            },
            'fnDrawCallback': function () {
                $.Common.Bootstrap.Tooltip(this);
                this.ofnDrawCallback();
            },
            'selectOpt': {}
        });
        //endregion
    });
</script>